package com.glink.manage.mqtt.model;


import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@ToString
public class MqttPicAnalyseResult implements Serializable {
    
    private static final long serialVersionUID = 511227261211744297L;
    
    private String nodeId;
    private String requestId;
//    private List<PicResult> resultsList;

    public Set<String> needUploadImageList() {
        if (this.requestId != null && this.requestId.startsWith("aiMark_")) {
            return null;
        }
        Set<String> imageList = new HashSet<>();
//        for (PicResult picResult : this.resultsList) {
//            if(CollectionUtils.isEmpty(picResult.getResults())){
//                continue;
//            }
//            for (PointResult pointResult : picResult.getResults()) {
//
//                if (StringUtils.isNotEmpty(pointResult.getResImageUrl()) &&
//                        pointResult.getResImageUrl().contains("_result")) {
//                    imageList.add(pointResult.getResImageUrl());
//                }
//            }
//        }
        return imageList;
    }


    public boolean validatedMessage() {
        if (StringUtils.isAnyEmpty(this.nodeId, this.requestId)) {
            return false;
        }
//        if (CollectionUtils.isEmpty(this.resultsList)) {
//            return false;
//        }
//        for (PicResult picResult : this.resultsList) {
//            if (picResult.getResults().isEmpty()) {
//                return false;
//            }
//  
//            for (PointResult result : picResult.getResults()) {
//                if (CollectionUtils.isEmpty(result.getPos()) || result.getResImageUrl() == null) {
//                    return false;
//                }
//                if (result.getCode() == 2000 && (
//                        StringUtils.isAnyEmpty(result.getType(), result.getResImageUrl(), result.getDesc()) || result.getPos() == null)) {
//                    return false;
//                }
//            }
//        }

        return true;
    }


//    public static MqttPicAnalyseResult createErrorResult(PicAnalyseDTO dto, int code, String desc) {
//        MqttPicAnalyseResult result = new MqttPicAnalyseResult();
//        result.setRequestId(dto.getRequestId());
//        List<PicResult> resultsList = new ArrayList<>();
//        result.setResultsList(resultsList);
//        for (PicAnalysePointDTO pointDTO : dto.getObjectList()) {
//            PicResult picResult = new PicResult();
//            resultsList.add(picResult);
//            picResult.setObjectId(pointDTO.getObjectId());
//            List<PointResult> pointResultList = new ArrayList<>();
//            picResult.setResults(pointResultList);
//            for (String type : pointDTO.getTypeList()) {
//                PointResult pointResult = new PointResult();
//                pointResultList.add(pointResult);
//                pointResult.setType(type);
//                pointResult.setValue("");
//                pointResult.setCode(code);
//                pointResult.setResImageUrl("");
//                pointResult.setPos(Collections.EMPTY_LIST);
//                pointResult.setConf(0.0F);
//                pointResult.setDesc(desc);
//            }
//        }
//        return result;
//    }

    public String getNodeId() {
        return this.nodeId;
    }

    public String getRequestId() {
        return this.requestId;
    }

//    public List<PicResult> getResultsList() {
//        return this.resultsList;
//    }
}
 
 